/**
 * Description:
 * Class Name:ReadFromProcess
 * Date:2022/5/2 15:34
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第15章_输入输出._15_6_Java虚拟机读写其他进程的数据;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ReadFromProcess {
    public static void main(String[] args) throws IOException {
        Process p = Runtime.getRuntime().exec("javac");
        try (
                // 对本程序来说是输入流，对p进程来说是输出流
                var br = new BufferedReader(new InputStreamReader(p.getInputStream()))
                ){
            String buff = null;
            while ((buff = br.readLine()) != null){
                System.out.println(buff);
            }
        }
    }
}
